package com.hst.web.base.web;

import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.hst.core.ServiceContext;
import com.hst.core.dao.IORDao;
import com.hst.core.dao.ISQLDao;
import com.hst.core.dao.ORQuery;
import com.hst.core.dao.ORQuery.Op;
import com.hst.core.json.JsonUtil;
import com.hst.web.auth.po.User;
import com.hst.web.base.entity.TCompanyEmployee;
import com.hst.web.base.entity.TFlowConfig;
import com.hst.web.base.entity.TFlowConfigDetail;
import com.hst.web.base.entity.TFlowHistory;
import com.hst.web.base.entity.TFlowTask;
import com.hst.web.base.service.VehicleCardService;
import com.hst.web.base.ui.CompanyEmployee;
import com.hst.web.base.ui.CompanyVehicle;
import com.hst.web.base.ui.FlowHistory;
import com.hst.web.base.ui.FlowTask;
import com.hst.web.base.ui.VehicleCardApprove;
import com.hst.web.sys.entity.TRole;

@Controller
@RequestMapping("/vehicleyearcheck")
public class VehicleYearCheckController {
	
	@Autowired
	ISQLDao sql;

	@Autowired
	IORDao dao;
	
	@Autowired
	VehicleCardService service;
	
	@SuppressWarnings({ "unchecked" })
	private Map<String, Object> parseQuerys(String data) throws JsonParseException, JsonMappingException, IOException {
		Map<String, Object> querys = JsonUtil.read(data, Map.class);
		return querys;
	}
	
	@RequestMapping("/applyYearCheck")
	public void applyCard(@RequestBody String data, Model m) throws JsonParseException, JsonMappingException, IOException {
		Map<String,Object> params = parseQuerys(data);
		String cardType = (String) params.get("cardType");
		String remark = (String) params.get("remark");
		String vechileStr = (String) params.get("vechiles");
		List<CompanyVehicle> emps = JsonUtil.readList(vechileStr, CompanyVehicle.class);
		service.applyYearCheck(cardType, remark, emps, m);
	}

}
